<?php  
  
function list_komponen_detail($komponen_id ,$start , $end){
	$header = array(
		'NIK'=>array('style'=>'text-align:left;border-bottom:2px solid;width:100px'),  
		'Nama'=>array('style'=>'text-align:left;border-bottom:2px solid;width:400px'),  
		'Nominal'=>array('style'=>'text-align:left;border-bottom:2px solid;width:120px'),  
	);
	$query = "SELECT karyawan_id,kalkulasi 
		FROM pr_gaji_komponen 
		WHERE periode_id=0 
		AND komponen_id={$komponen_id} 
		ORDER BY karyawan_id LIMIT $start , $end"
	;
 
	$result = my_query($query);
	 
	while($ey = my_fetch_array($result)){
		$karyawan_temp=$ey['karyawan_id'];
		$karyawan = loaddata_karyawan($ey['karyawan_id']);
		$row[] = array(
			'nik'=> $karyawan['nik'] ,     
			'gd'=>  $karyawan['nama_gelar'] ,  
			'nominal'=>   rp_format($ey['kalkulasi']) ,      
		); 
	}
	$datas = table_cetak_rows($row);
	 
	return table_cetak_builder($header , $datas ,  6   );
}

function get_tanggal_by_periode_id(){
	$periode_id =get_periode_gaji();
	$periodes = my_get_data_by_id('pr_periode','periode_id',$periode_id);
	$bulan = (int) date('m' , strtotime($periodes['tanggal']));
	$tahun = $periodes['tahun'] ;
	return sprintf( '%02d',$bulan).'-'.$tahun ;
}
?>
<style type="text/css">
<!--

	table.page_header {width: 100%; border: none; background-color: #CDCDCD; border-bottom: solid 1mm #000; padding: 2mm }
	table.page_footer {width: 100%; border: none;  border-top: solid 1mm #000; padding: 2mm}
div.zone
{
	border: solid 2mm #66AACC;
	border-radius: 3mm;
	padding: 1mm;
	background-color: #FFEEEE;
	color: #440000;
}
div.zone_over
{
	width: 30mm;
	height: 35mm;
	overflow: hidden;
}

-->
</style>  
	<?php 
$query = "SELECT karyawan_id,kalkulasi 
		FROM pr_gaji_komponen 
		WHERE periode_id=0 
		AND komponen_id={$_GET['komponen_id']} 
		ORDER BY karyawan_id ";
	$result = my_query($query);
	$total = my_num_rows($result);
	$limit = 30;
	$total_page = ceil($total/$limit) -1; 
	
	$komponens=my_get_data_by_id('pr_komponen_gaji','komponen_gaji_id',$_GET['komponen_id']	);
	for($i = 0; $i<=  $total_page  ;$i++):
	$start =  ( $i * $limit );
	
?>	  	 
<page style="font-size: 10pt">
	<page_footer>
		<table class="page_footer">
			<tr>
				<td style="width: 33%; text-align: left;">
					 HRIS RSKM 
				</td>
				<td style="width: 34%; text-align: center">
					page [[page_cu]]/[[page_nb]]
				</td>
				<td style="width: 33%; text-align: right">
					M A P &copy; 2010 - <?php echo date('Y'); ?>
				</td>
			</tr>
		</table>
	</page_footer>
	<?php if($i ==0){ ?>
	 
	<div style="width: 100%; text-align:center; padding:2px; font-size: 13pt ;">REKAP PEMBAYARAN GAJI PER KOMPONEN<br> </div>
	
	<br><?php } ?>
	<table style="width:100%;">
	<tr>
		<td style="font-size:12px;width:35%;height:20px;">NAMA KOMPONEN GAJI</td>
		<td style="width:65%"><?php echo $komponens['nama_komponen_gaji'];?></td>
	</tr>
	<tr>
		<td style="font-size:12px;width:35%;height:20px;">Periode Gaji</td>
		<td style="width:65%"><?php echo get_tanggal_by_periode_id();?></td>
	</tr>
	</table><br>
	
	<?php echo list_komponen_detail($_GET['komponen_id'] , $start , $limit); ?> 
</page> 
<?php endfor; ?>